<template>
  <div class="dog">
    <img :src="imgUrl" alt="" />
    <p :style="{ backgroundColor: colorName }" @click="changeColor">
      {{ dogName }}
    </p>
  </div>
</template>

<script>
export default {
  props: ['imgUrl', 'dogName'],
  data() {
    return {
      colorName: '',
    }
  },
  methods: {
    changeColor() {
      this.colorName = `rgb(${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)})`
    },
  },
}
</script>

<style>
.dog {
  float: left;
  border: 1px solid black;
  text-align: center;
  width: 200px;
}
img {
  width: 100%;
  height: 200px;
}
</style>
